//package com.baidu.yyb.core.TTS;
//
//
//import android.content.Context;
//import android.media.AudioManager;
//import android.util.Log;
//
//import com.baidu.tts.auth.AuthInfo;
//import com.baidu.tts.client.SpeechSynthesizeBag;
//import com.baidu.tts.client.SpeechSynthesizer;
//import com.baidu.tts.client.TtsMode;
//import com.baidu.yyb.AlertDialogUI.ShowToast;
//import com.lt.database.DataBases.TtsDataSetting;
//
//import java.util.ArrayList;
//import java.util.List;
//
//public class AudioUtils {
//
//    private static final String TEMP_DIR = "/sdcard/baiduTTS";
//    private static final String TEXT_MODEL = null;
//    private static final String TEXT_FILENAME = TEMP_DIR + "/" + TEXT_MODEL;
//    private static final String VOICE_MALE_MODEL = null;
//    private static final String MODEL_FILENAME = TEMP_DIR + "/" + VOICE_MALE_MODEL;
//    private static AudioUtils audioUtils;
//    private final String appId = "8535996";
//    private final String appKey = "MxPpf3nF5QX0pndKKhS7IXcB";
//    private final String secretKey = "7226e84664474aa098296da5eb2aa434";
//    private final TtsMode ttsMode = TtsMode.ONLINE;  // 在线
//    protected SpeechSynthesizer mSpeechSynthesizer;
//    private ShowToast st;
//    private TtsDataSetting TtsData = new TtsDataSetting(0, 5, 5, 5);
//
//    private AudioUtils() {
//    }
//
//    public static AudioUtils getInstance() {
//        if (audioUtils == null) {
//            synchronized (AudioUtils.class) {
//                if (audioUtils == null) {
//                    audioUtils = new AudioUtils();
//                }
//            }
//        }
//        return audioUtils;
//    }
//
//    public void getParameters(TtsDataSetting td) {
//        TtsData = td;
//    }
//
//    public void getSelect(int params) {
//        TtsData.Voice_Select = params;
//    }
//
//    public void getVolume(int params) {
//        TtsData.Voice_volume = params;
//    }
//
//    public void getSpeech(int params) {
//        TtsData.Voice_speed = params;
//    }
//
//    public void getTon(int params) {
//        TtsData.Voice_tone = params;
//    }//单个设置
//
//    public void initTTs(Context context) {
////        boolean isMix = ttsMode.equals(TtsMode.MIX);
//        boolean isSuccess;
//        mSpeechSynthesizer = SpeechSynthesizer.getInstance();
//        mSpeechSynthesizer.setContext(context);
//        int result = mSpeechSynthesizer.setAppId(appId);
//        checkResult(result, "setAppId");
//        result = mSpeechSynthesizer.setApiKey(appKey, secretKey);
//        checkResult(result, "setApiKey");
//        mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_SPEAKER, String.valueOf(TtsData.Voice_Select));
//        mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_VOLUME, String.valueOf(TtsData.Voice_volume));
//        mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_SPEED, String.valueOf(TtsData.Voice_speed));
//        mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_PITCH, String.valueOf(TtsData.Voice_tone));
//        mSpeechSynthesizer.setParam(SpeechSynthesizer.PARAM_MIX_MODE, SpeechSynthesizer.MIX_MODE_HIGH_SPEED_NETWORK);
//        mSpeechSynthesizer.setAudioStreamType(AudioManager.MODE_IN_CALL);
//        result = mSpeechSynthesizer.initTts(ttsMode);
//        checkResult(result, "initTts");
//    }
//
//
//    private boolean checkAuth() {
//        AuthInfo authInfo = mSpeechSynthesizer.auth(ttsMode);
//        if (!authInfo.isSuccess()) {
//            String errorMsg = authInfo.getTtsError().getDetailMessage();
//            Log.e("msg", "【error】鉴权失败 errorMsg=" + errorMsg);
//            return false;
//        } else {
//            Log.e("msg", "验证通过，离线正式授权文件存在。");
//            return true;
//        }
//    }
//
//
//    private void checkResult(int result, String method) {
//        if (result != 0) {
//        }
//    }
//
//
//    public void speak(String text) {
//        int result = mSpeechSynthesizer.speak(text);
//        checkResult(result, "speak");
//    }
//
//    public void stop() {
//        int result = mSpeechSynthesizer.stop();
//        checkResult(result, "stop");
//    }
//
//    public void Release() {
//        if (mSpeechSynthesizer != null) {
//            mSpeechSynthesizer.stop();
//            mSpeechSynthesizer.release();
//            mSpeechSynthesizer = null;
//        }
//    }
//
//
//    public void BatchSpeak(ArrayList<String> list) {
//        List<SpeechSynthesizeBag> bags = new ArrayList<SpeechSynthesizeBag>();
//        for (int i = 0; i < list.size(); i++) {
//            String tag = String.valueOf(i);
//            bags.add(getSpeechSynthesizeBag(list.get(i), tag));
//        }
//        int result = mSpeechSynthesizer.batchSpeak(bags);
//    }
//
//
//    private SpeechSynthesizeBag getSpeechSynthesizeBag(String text, String utteranceId) {
//        SpeechSynthesizeBag speechSynthesizeBag = new SpeechSynthesizeBag();
//        speechSynthesizeBag.setText(text);
//        speechSynthesizeBag.setUtteranceId(utteranceId);
//        return speechSynthesizeBag;
//    }
//
//}